function x_est = sphere_detector(y, H, radius)
    % 获取系统大小
    [Nr, Nt] = size(H);
    
    % QR分解
    [Q, R] = qr(H);
    y_tilde = Q' * y;
    
    % 初始化
    x_est = zeros(Nt, 1);
    best_metric = inf;
    best_solution = zeros(Nt, 1);
    
    % 定义QPSK符号集
    symbols = [-1-1i, -1+1i, 1-1i, 1+1i];
    
    % 递归搜索函数
    function search(level, partial_metric, partial_solution)
        if partial_metric > best_metric
            return;
        end
        
        if level == 0
            if partial_metric < best_metric
                best_metric = partial_metric;
                best_solution = partial_solution;
            end
            return;
        end
        
        % 计算中心点
        sum_term = 0;
        for j = level+1:Nt
            sum_term = sum_term + R(level,j)*partial_solution(j);
        end
        center = (y_tilde(level) - sum_term)/R(level,level);
        
        % 对每个可能的符号进行测试
        for s = symbols
            new_solution = partial_solution;
            new_solution(level) = s;
            
            new_metric = partial_metric + abs(y_tilde(level) - sum_term - R(level,level)*s)^2;
            
            if new_metric <= radius^2
                search(level-1, new_metric, new_solution);
            end
        end
    end

    % 开始搜索
    initial_solution = zeros(Nt, 1);
    search(Nt, 0, initial_solution);
    
    x_est = best_solution;
end 